<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>EOS.IO: Dual Index Table</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="eos-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">EOS.IO
   &#160;<span id="projectnumber">DAWN3.0.1</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a>  </div>
  <div class="headertitle">
<div class="title">Dual Index Table<div class="ingroups"><a class="el" href="group__contractdev.html">Smart Contract API Reference</a> &raquo; <a class="el" href="group__database.html">Database API</a> &raquo; <a class="el" href="group__database_cpp.html">Database C++ API</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Defines a type-safe C++ wrapper around the C Dual Index Table.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structeosio_1_1table.html">eosio::table&lt; scope, code, table_n, Record, PrimaryType, SecondaryType &gt;</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">scope</td><td>- the default account name/scope that this table is located within </td></tr>
    <tr><td class="paramname">code</td><td>- the code account name which has write permission to this table </td></tr>
    <tr><td class="paramname">table</td><td>- a unique identifier (name) for this table </td></tr>
    <tr><td class="paramname">Record</td><td>- the type of data stored in each row </td></tr>
    <tr><td class="paramname">PrimaryType</td><td>- the type of the first field stored in Record </td></tr>
    <tr><td class="paramname">SecondaryType</td><td>- the type of the second field stored in Record</td></tr>
  </table>
  </dd>
</dl>
<p>The primary and secondary indices are sorted as N-bit unsigned integers from lowest to highest.</p>
<div class="fragment"><div class="line"><span class="keyword">struct </span>model {</div><div class="line">    <a class="code" href="group__types.html#gaaa5d1cd013383c889537491c3cfd9aad">uint64_t</a> <a class="code" href="test__db_8cpp.html#af15b5e608a0fbe8c184ab90b3791413f">primary</a>;</div><div class="line">    <a class="code" href="group__types.html#gaaa5d1cd013383c889537491c3cfd9aad">uint64_t</a> <a class="code" href="test__db_8cpp.html#a52c20999685338b5763f129033f2c1d9">secondary</a>;</div><div class="line">    <a class="code" href="group__types.html#gaaa5d1cd013383c889537491c3cfd9aad">uint64_t</a> value;</div><div class="line">};</div><div class="line"></div><div class="line"><span class="keyword">typedef</span> table&lt;N(myscope), N(mycode), N(mytable), model, uint64_t, uint64_t&gt; MyTable;</div><div class="line">model a { 1, 11, <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(first) };</div><div class="line">model b { 2, 22, <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(second) };</div><div class="line">model c { 3, 33, <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(third) };</div><div class="line">model d { 4, 44, <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(fourth) };</div><div class="line"></div><div class="line"><span class="keywordtype">bool</span> res = MyTable::store(a);</div><div class="line">ASSERT(res, <span class="stringliteral">&quot;store&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::store(b);</div><div class="line">ASSERT(res, <span class="stringliteral">&quot;store&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::store(c);</div><div class="line">ASSERT(res, <span class="stringliteral">&quot;store&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::store(d);</div><div class="line">ASSERT(res, <span class="stringliteral">&quot;store&quot;</span>);</div><div class="line"></div><div class="line">model query;</div><div class="line">res = <a class="code" href="group__accountcppapi.html#gadae5fc018a536331426f04923781d3ed">MyTable::primary_index::get</a>(1, query);</div><div class="line">ASSERT(res &amp;&amp; query.primary == 1 &amp;&amp; query.value == <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(first), <span class="stringliteral">&quot;first&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::primary_index::front(query);</div><div class="line">ASSERT(res &amp;&amp; query.primary == 4 &amp;&amp; query.value == <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(fourth), <span class="stringliteral">&quot;front&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::primary_index::back(query);</div><div class="line">ASSERT(res &amp;&amp; query.primary == 1 &amp;&amp; query.value == <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(first), <span class="stringliteral">&quot;back&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::primary_index::previous(query);</div><div class="line">ASSERT(res &amp;&amp; query.primary == 2 &amp;&amp; query.value == <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(second), <span class="stringliteral">&quot;previous&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::primary_index::next(query);</div><div class="line">ASSERT(res &amp;&amp; query.primary == 1 &amp;&amp; query.value == <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(first), <span class="stringliteral">&quot;first&quot;</span>);</div><div class="line"></div><div class="line">res = <a class="code" href="group__accountcppapi.html#gadae5fc018a536331426f04923781d3ed">MyTable::secondary_index::get</a>(11, query);</div><div class="line">ASSERT(res &amp;&amp; query.primary == 11 &amp;&amp; query.value == <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(first), <span class="stringliteral">&quot;first&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::secondary_index::front(query);</div><div class="line">ASSERT(res &amp;&amp; query.secondary == 44 &amp;&amp; query.value == <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(fourth), <span class="stringliteral">&quot;front&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::secondary_index::back(query);</div><div class="line">ASSERT(res &amp;&amp; query.secondary == 11 &amp;&amp; query.value == <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(first), <span class="stringliteral">&quot;back&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::secondary_index::previous(query);</div><div class="line">ASSERT(res &amp;&amp; query.secondary == 22 &amp;&amp; query.value == <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(second), <span class="stringliteral">&quot;previous&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::secondary_index::next(query);</div><div class="line">ASSERT(res &amp;&amp; query.secondary == 11 &amp;&amp; query.value == <a class="code" href="group__types.html#gaf9c1edb0e0da55ec6ba09f32f6839529">N</a>(first), <span class="stringliteral">&quot;first&quot;</span>);</div><div class="line"></div><div class="line">res = MyTable::remove(query);</div><div class="line">ASSERT(res, <span class="stringliteral">&quot;remove&quot;</span>);</div><div class="line"></div><div class="line">res = <a class="code" href="group__accountcppapi.html#gadae5fc018a536331426f04923781d3ed">MyTable::get</a>(query);</div><div class="line">ASSERT(!res, <span class="stringliteral">&quot;not found already removed&quot;</span>);</div></div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
